using System;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions;
using Coderoom.ScrumPlanner.Resources;

namespace Coderoom.ScrumPlanner.Domain
{
	public abstract class Entity
	{
		#region Properties

		public Guid Id { get; set; }

		[Required(ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = "Entity_TitleNotSpecified")]
		public string Title { get; set; }

		[Required(ErrorMessageResourceType = typeof(ValidationMessages), ErrorMessageResourceName = "Entity_SlugNotSpecified")]
		public string Slug { get; set; }

		#endregion

		[SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase")]
		public static string CreateSlug(string title)
		{
			return Regex.Replace(title, @"( |\.)", "-", RegexOptions.Compiled).ToLowerInvariant();
		}
	}
}
